using System;
using System.Collections.Generic;
using System.Text;
using IronPython.Hosting;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
using Microsoft.Scripting.Runtime;

namespace EngineExecuteDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            ScriptEngine engine = PythonEngine.CurrentEngine;
            string statements = "y = 24 + x\n" +
                                "print 'y =', y";
            ScriptScope defaultModule = engine.Runtime.Host.DefaultScope;
            
            defaultModule.SetVariable("x", 42);
            engine.CreateScriptSourceFromString(statements,SourceCodeKind.Statements).Execute(defaultModule);
            ScriptScope module1 = engine.CreateScope();
            module1.SetVariable("x", 3033);
            int iX = engine.CreateScriptSourceFromString("x").Execute<int>(module1);
            Console.WriteLine(iX);
            Console.Read();
      

        }
    }
}
